﻿<Window x:Class="XQueryConsole.CreateTableDialog"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:avalonEdit="http://icsharpcode.net/sharpdevelop/avalonedit"
        xmlns:w="clr-namespace:XQueryConsole"
        Title="Result Table Definition" Height="363" Width="413"        
        WindowStartupLocation="CenterOwner" ShowInTaskbar="False" 
        TextOptions.TextFormattingMode="Display" MinHeight="300" MinWidth="400">
    <Grid Margin="5,5,8,8">
        <Grid.ColumnDefinitions>
            <ColumnDefinition/>
            <ColumnDefinition Width="Auto"/>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
        <StackPanel Grid.Row="0" Grid.Column="0">
            <Label>SQL Data Source</Label>
            <ComboBox Name="dataSourceCombo"  Width="250" HorizontalAlignment="Left" ItemsSource="{Binding}" 
                      SelectedItem="{Binding RelativeSource={RelativeSource AncestorType=w:CreateTableDialog}, 
                          Path=DataSource, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"></ComboBox>
        </StackPanel>
        <StackPanel Grid.Row="1" Grid.Column="0">
            <Label>Table Name</Label>
            <TextBox Width="150" HorizontalAlignment="Left" Text="{Binding RelativeSource={RelativeSource AncestorType=w:CreateTableDialog}, 
                Path=TableName, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"></TextBox>
        </StackPanel>
        <Grid Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2" Margin="0,10,0,5">
            <Grid.ColumnDefinitions>
                <ColumnDefinition></ColumnDefinition>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="*"/>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>
            <Border Grid.Row="1"  Grid.Column="0" BorderBrush="{x:Static SystemColors.ActiveBorderBrush}" BorderThickness="1">
                <avalonEdit:TextEditor Name="textEditor" FontFamily="Consolas" Margin="15,0,0,0"
				    FontSize="9pt" WordWrap="True">
                </avalonEdit:TextEditor>
            </Border>
        </Grid>
        <CheckBox Grid.Row="3" Grid.Column="0" IsChecked="{Binding RelativeSource={RelativeSource AncestorType=w:CreateTableDialog}, 
                Path=AutoGenerateDDL, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">Auto generate DDL</CheckBox>
        <StackPanel Grid.Row="0" Grid.Column="1">
            <Button Name="okButton" IsDefault="True" Margin="3,0,0,0" Width="80" Click="okButton_Click" 
                    IsEnabled="{Binding RelativeSource={RelativeSource AncestorType=w:CreateTableDialog}, 
                            Path=IsOkButtonEnabled, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}">OK</Button>
            <Button IsCancel="True"  Margin="3,5,0,0">Cancel</Button>
        </StackPanel>
    </Grid>    
</Window>
